home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
Z4PFEX.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-02
|
4KB
|
136 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: z4pfex.c
// Title: ZIP+4 Engine
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
//
// This module contains the expander for the POF file.
// This module should not use any global variables since it must be
// re-entrant.
//
// The code in this module should be written entirely in C.
// Do not use any C++ constructs.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
// SCO UNIX.
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
// SCO UNIX cc
//
//----------------------------------------------------------------------------
#include <z4.h>
//----------------------------------------------------------------------------
// Description: Read a compressed record from the output buffer.
// Parameters: pblk Decoder data structure
// pctyst ZIP5 record
// Returns: TRUE if successful.
// FALSE if no more records found to decode.
//----------------------------------------------------------------------------
BOOL FN_E Z4PFExpand(PZ4_PF_BLK pblk, PZ4_PF ppf)
{
PBYTE pb;
SIZET cb;
Assert(pblk && ppf);
memset(&pblk->pf, 0, sizeof(pblk->pf));
// Must be at end of buffer
if (pblk->cbNext + MAX_FINANCE_BCD + sizeof(USHORT) + MAX_ZIP5_BCD >= pblk->cb)
return FALSE;
pb = pblk->pb + pblk->cbNext; // Decode ZIP5
if (pb[0] == 0) // Block not full, but no more records
{
pblk->cbNext = pblk->cb;
return FALSE;
}
strb2a(pb, MAX_FINANCE_BCD, pblk->pf.szFinance, MAX_FINANCE, TRUE);
pb += MAX_FINANCE_BCD;
pblk->pf.cZip5 = (SIZET)*(PUSHORT)pb;
pb += sizeof(USHORT);
cb = MAX_ZIP5_BCD * pblk->pf.cZip5;
memcpy(pblk->pf.abZip5, pb, cb);
pb += cb;
cb = (SIZET)(pb - pblk->pb);
Assert(cb <= pblk->cb);
pblk->cbNext = cb;
*ppf = pblk->pf; // Return a copy of the current record
return TRUE;
}
//----------------------------------------------------------------------------
// Description: Initialize expander
// Parameters: pblk Decoder data structure
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
BOOL FN_E Z4PFExpandInitialize(PZ4_PF_BLK pblk)
{
Assert(pblk);
memset(pblk, 0, sizeof(Z4_PF_BLK));
return TRUE;
}
//----------------------------------------------------------------------------
// Description: Reset expander to decode another block of data.
// Parameters: pblk Decoder data structure
// pb Buffer containing compressed data.
// cb Size of buffer.
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
BOOL FN_E Z4PFExpandReset(PZ4_PF_BLK pblk, PBYTE pb, SIZET cb)
{
Assert(pblk);
pblk->pb = pb; // Set decoding pointers
pblk->cb = cb;
pblk->cbNext = 0;
return TRUE;
}
//----------------------------------------------------------------------------
// Description: Terminate expander.
// Parameters: pblk Decoder data structure
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
BOOL FN_E Z4PFExpandTerminate(PZ4_PF_BLK pblk)
{
Assert(pblk);
memset(pblk, 0, sizeof(Z4_PF_BLK));
return TRUE;
}
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------